<?php
/*
 * @Description: 
 * @Author: Leequik
 * @Date: 2025-03-21 22:20:52
 * @LastEditTime: 2025-07-28 00:22:53
 * @LastEditors: Leequik
 */

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Events\TestEvent;
use App\Services\SendMessageService;
use App\Jobs\SendMsgJob;

class QueueDaley extends Command
{
    /**
     * The name and signature of the console command.
     * 队列名称：app:queue-daley
     * 
     * 发送队列命令：php artisan app:queue-daley
     * 
     * @var string
     */
    protected $signature = 'app:send-daley';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '延时队列';

    /**
     * Execute the console command.
     */
    public function handle()
    {
        //
        $this->sed();
    }

    public function sed(){
        //$this->match_test('a');
        //$this->match_test('b');

        $this->sendMsgJob('c');
       //$this->redisTest();
    }


    public function sendMsgJob($type){
        $queue = 'daley_queue';
        //调用服务
        if($type && in_array($type, ['a', 'b', 'c'])) { 

         SendMsgJob::dispatch($type)->delay(now()->addMinute(1))
         ->onQueue($queue);
        $this->info('延迟队列=>任务已发送到队列！');

        //return response()->json(['message' => 'Job dispatched for type: ' . $type]);
        
        }

    }


}
